package com.qst.express.controller.wx;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.qst.commonUtils.result.R;
import com.qst.express.entity.Courier;
import com.qst.express.entity.User;
import com.qst.express.service.CourierService;
import com.qst.express.service.UserService;
import com.qst.express.utils.UserUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author:CoolTiger
 * @title: IndexController
 * @projectName springboot-e
 * @description: TODO
 * @date:2022/09/27/16:01:19
 **/
@Controller
@Slf4j
public class IndexController {
    @Autowired
    private UserService userService;
    @Autowired
    private CourierService courierService;

    // 跳转个人中心界面
    @GetMapping("/e/wxUserhome")
    public String wxUserhome(HttpServletRequest request) {
        return "e/user/wxUserhome";
    }
    //跳转主页面
    @GetMapping("/e/index")
    public String toIndex() {
        return "index";
    }
    //跳转到单号查询页面
    @GetMapping("/e/toExpressByNumber/{number}")
    public String expressByNumber(@PathVariable(value = "number",required = false) String number,Model model) {
        model.addAttribute("number",number);
        return "e/express/expressByNumber";
    }
    //跳转用户信息修改页面
    @GetMapping("/e/wx/toWxIdCardUserInfoModify")
    public String wxIdCardUserInfoModify() {
        return "e/user/wxIdCardUserInfoModify";
    }
    //跳转个人中心认证
    @GetMapping("/userCheckStart")
    public String userCheckStart() {
        return "e/user/userCheckStart";
    }

    // 懒人排行榜页面跳转
    @GetMapping("/e/lazyboard")
    public String lazyboard() {
        return "e/lazyboard";
    }

    //跳转快递列表
    @GetMapping("/e/expressList")
    public String expressList() {
        return "e/express/expressList";
    }
    //跳转到快递助手
    @GetMapping("/e/expressAssist")
    public String expressAssist() {
        return "e/express/expressAssist";
    }
    //跳转到快递助手-扫码取件
    @GetMapping("/e/wxJs")
    public String pickExpress() {
        return "e/express/pickExpress";
    }
    //跳转到快递助手-快递录入
    @GetMapping("/e/addExpress")
    public String addExpress() {
        return "e/express/addExpress";
    }
    //跳转到快递助手-历史快递
    @GetMapping("/e/infoExpress")
    public String infoExpress() {
        return "e/express/infoExpress";
    }
    // 跳转到登录页面
    @GetMapping("/e/logout")
    public String logout(HttpServletRequest request) {
        //销毁session
        request.getSession().invalidate();
        return "e/login";
    }

    // 跳转到登录页面
    @GetMapping("/")
    public String main(Model model, HttpServletRequest request) {
        log.info("当前方法是：{}", "main");
        String msg = (String) request.getAttribute("msg");
        System.out.println(msg);
        model.addAttribute("msg", msg);
        return "e/login";
    }

    // 跳转到主页面
    @GetMapping("/index")
    public String main() {
        return "index";
    }

}
